/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.IronTowerBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class IronTowerDAO
/*     */ {
/*  21 */   private static final Log log = LogFactory.getLog(IronTowerDAO.class);
/*  22 */   private dbConnector dbcon = null;
/*  23 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*  24 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*     */ 
/*     */   private void dbConInit() {
/*  27 */     if (this.dbcon == null)
/*  28 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  32 */     if (this.dbcon != null)
/*  33 */       this.dbcon.closeAll();
/*  34 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getIronTowerBOList(Map condition)
/*     */   {
/*  39 */     ListContentsBFO bfo = new ListContentsBFO();
/*  40 */     int start = Integer.parseInt(condition.get("start").toString());
/*  41 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  42 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  43 */     ResultSet rs = null;
/*  44 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  47 */       dbConInit();
/*  48 */       String strSQL = " select count(id) from irontower where btscode = '" + strBtscode + "' ";
/*  49 */       log.info(strSQL);
/*  50 */       rs = this.dbcon.execQuery(strSQL);
/*  51 */       if (rs.next()) {
/*  52 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  54 */       strSQL = " select * from irontower where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  55 */       log.info(strSQL);
/*  56 */       rs = this.dbcon.execQuery(strSQL);
/*  57 */       while (rs.next()) {
/*  58 */         IronTowerBO bo = new IronTowerBO();
/*  59 */         bo.setId(rs.getString("id"));
/*  60 */         bo.setBtscode(rs.getString("btscode"));
/*  61 */         bo.setBtsname(rs.getString("btsname"));
/*  62 */         bo.setType(rs.getString("type"));
/*  63 */         bo.setProperty(rs.getString("property"));
/*  64 */         bo.setOpentime(rs.getDate("registtime"));
/*  65 */         bo.setFromunit(rs.getString("fromunit"));
/*  66 */         bo.setContact(rs.getString("contact"));
/*  67 */         bo.setTelphone(rs.getString("telphone"));
/*  68 */         bo.setHeight(rs.getString("height"));
/*  69 */         bo.setWarnschilder(rs.getString("warnschilder"));
/*  70 */         bo.setMaintenance(rs.getString("maintenance"));
/*  71 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  72 */         bo.setMemo(rs.getString("memo"));
/*  73 */         bo.setItowerPlatNum(rs.getString("itowerPlatNum"));
/*  74 */         bo.setItowerSta(rs.getString("itowerSta"));
/*  75 */         list.add(bo);
/*     */       }
/*  77 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  80 */       e.printStackTrace();
/*  81 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  84 */       dbConClose();
/*     */     }
/*  86 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveIronTowerBO(IronTowerBO bo)
/*     */   {
/*  91 */     log.info("添加--铁塔---开始");
/*  92 */     boolean flag = true;
/*     */     try
/*     */     {
/*  95 */       dbConInit();
/*  96 */       StringBuffer sqlBuf = new StringBuffer();
/*  97 */       sqlBuf.append(" insert into irontower ( btscode, btsname, property, registtime,");
/*  98 */       sqlBuf.append(" fromunit, contact, telphone, type, height,  warnschilder, maintenance,");
/*  99 */       sqlBuf.append(" refreshtime, memo, itowerPlatNum, itowerSta  ) values ( ");
/* 100 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 101 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 102 */       sqlBuf.append(" '" + bo.getProperty() + "' ,");
/* 103 */       sqlBuf.append(" '" + this.open.format(bo.getOpentime()) + "' ,");
/* 104 */       sqlBuf.append(" '" + bo.getFromunit() + "' ,");
/* 105 */       sqlBuf.append(" '" + bo.getContact() + "' ,");
/* 106 */       sqlBuf.append(" '" + bo.getTelphone() + "' ,");
/* 107 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getHeight() + "' ,");
/* 109 */       sqlBuf.append(" '" + bo.getWarnschilder() + "' ,");
/* 110 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 111 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "', ");
/* 112 */       sqlBuf.append(" '" + bo.getMemo() + "' , ");
/* 113 */       sqlBuf.append(" '" + bo.getItowerPlatNum() + "' , ");
/* 114 */       sqlBuf.append(" '" + bo.getItowerSta() + "' ) ");
/* 115 */       log.info(sqlBuf.toString());
/* 116 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 120 */       flag = false;
/* 121 */       e.printStackTrace();
/* 122 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 125 */       dbConClose();
/*     */     }
/* 127 */     log.info("添加--铁塔---结束");
/* 128 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateIronTowerBO(IronTowerBO bo)
/*     */   {
/* 133 */     log.info("修改--铁塔---开始");
/* 134 */     boolean flag = true;
/*     */     try
/*     */     {
/* 137 */       dbConInit();
/* 138 */       StringBuffer sqlBuf = new StringBuffer();
/* 139 */       sqlBuf.append(" update irontower  set ");
/* 140 */       sqlBuf.append(" property = '" + bo.getProperty() + "' ,");
/* 141 */       sqlBuf.append(" registtime = '" + this.open.format(bo.getOpentime()) + "' ,");
/* 142 */       sqlBuf.append(" fromunit = '" + bo.getFromunit() + "' ,");
/* 143 */       sqlBuf.append(" contact = '" + bo.getContact() + "' ,");
/* 144 */       sqlBuf.append(" telphone = '" + bo.getTelphone() + "' ,");
/* 145 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 146 */       sqlBuf.append(" height = '" + bo.getHeight() + "' ,");
/* 147 */       sqlBuf.append(" warnschilder = '" + bo.getWarnschilder() + "' ,");
/* 148 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 149 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "', ");
/* 150 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' , ");
/* 151 */       sqlBuf.append(" itowerPlatNum = '" + bo.getItowerPlatNum() + "' , ");
/* 152 */       sqlBuf.append(" itowerSta = '" + bo.getItowerSta() + "'  ");
/* 153 */       sqlBuf.append(" where id='" + bo.getId() + "'");
/* 154 */       log.info(sqlBuf.toString());
/* 155 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 159 */       flag = false;
/* 160 */       e.printStackTrace();
/* 161 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 164 */       dbConClose();
/*     */     }
/* 166 */     log.info("修改--铁塔---结束");
/* 167 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteIronTowerBO(String strID)
/*     */   {
/* 173 */     log.info("删除--铁塔---开始");
/* 174 */     boolean flag = true;
/*     */     try
/*     */     {
/* 177 */       dbConInit();
/* 178 */       StringBuffer sqlBuf = new StringBuffer();
/* 179 */       sqlBuf.append(" delete from  irontower ");
/* 180 */       sqlBuf.append(" where id='" + strID + "'");
/* 181 */       log.info(sqlBuf.toString());
/* 182 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 186 */       flag = false;
/* 187 */       e.printStackTrace();
/* 188 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 191 */       dbConClose();
/*     */     }
/* 193 */     log.info("删除--铁塔---结束");
/* 194 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getIronTowerByBtsName(Map condition)
/*     */   {
/* 199 */     ListContentsBFO bfo = new ListContentsBFO();
/* 200 */     int start = Integer.parseInt(condition.get("start").toString());
/* 201 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 202 */     String strBtsName = condition.get("btsName").toString();
/* 203 */     ResultSet rs = null;
/* 204 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 207 */       dbConInit();
/* 208 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 209 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 212 */       String strSQL = " select count(id) from irontower where btsname like '%" + strBtsName + "%' ";
/* 213 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 214 */       log.info(strSQL);
/* 215 */       rs = this.dbcon.execQuery(strSQL);
/* 216 */       if (rs.next()) {
/* 217 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 219 */       strSQL = " select * from irontower where  btsname like '%" + strBtsName + "%' ";
/* 220 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 221 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 222 */       log.info(strSQL);
/* 223 */       rs = this.dbcon.execQuery(strSQL);
/* 224 */       while (rs.next()) {
/* 225 */         IronTowerBO bo = new IronTowerBO();
/* 226 */         bo.setId(rs.getString("id"));
/* 227 */         bo.setBtscode(rs.getString("btscode"));
/* 228 */         bo.setBtsname(rs.getString("btsname"));
/* 229 */         bo.setType(rs.getString("type"));
/* 230 */         bo.setProperty(rs.getString("property"));
/* 231 */         bo.setOpentime(rs.getDate("registtime"));
/* 232 */         bo.setFromunit(rs.getString("fromunit"));
/* 233 */         bo.setContact(rs.getString("contact"));
/* 234 */         bo.setTelphone(rs.getString("telphone"));
/* 235 */         bo.setHeight(rs.getString("height"));
/* 236 */         bo.setWarnschilder(rs.getString("warnschilder"));
/* 237 */         bo.setMaintenance(rs.getString("maintenance"));
/* 238 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 239 */         bo.setMemo(rs.getString("memo"));
/* 240 */         bo.setItowerPlatNum(rs.getString("itowerPlatNum"));
/* 241 */         bo.setItowerSta(rs.getString("itowerSta"));
/* 242 */         list.add(bo);
/*     */       }
/* 244 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 247 */       e.printStackTrace();
/* 248 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 251 */       dbConClose();
/*     */     }
/* 253 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 258 */     ResultSet rs = null;
/* 259 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 262 */       dbConInit();
/*     */ 
/* 264 */       String strSQL = " select * from irontower where  btsname like '%" + strBtsName + "%'   ";
/* 265 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 266 */       log.info(strSQL);
/* 267 */       rs = this.dbcon.execQuery(strSQL);
/* 268 */       while (rs.next()) {
/* 269 */         IronTowerBO bo = new IronTowerBO();
/* 270 */         bo.setId(rs.getString("id"));
/* 271 */         bo.setBtscode(rs.getString("btscode"));
/* 272 */         bo.setBtsname(rs.getString("btsname"));
/* 273 */         bo.setType(rs.getString("type"));
/* 274 */         bo.setProperty(rs.getString("property"));
/* 275 */         bo.setOpentime(rs.getDate("registtime"));
/* 276 */         bo.setFromunit(rs.getString("fromunit"));
/* 277 */         bo.setContact(rs.getString("contact"));
/* 278 */         bo.setTelphone(rs.getString("telphone"));
/* 279 */         bo.setHeight(rs.getString("height"));
/* 280 */         bo.setWarnschilder(rs.getString("warnschilder"));
/* 281 */         bo.setMaintenance(rs.getString("maintenance"));
/* 282 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 283 */         bo.setMemo(rs.getString("memo"));
/* 284 */         bo.setItowerPlatNum(rs.getString("itowerPlatNum"));
/* 285 */         bo.setItowerSta(rs.getString("itowerSta"));
/* 286 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 290 */       e.printStackTrace();
/* 291 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 294 */       dbConClose();
/*     */     }
/* 296 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.IronTowerDAO
 * JD-Core Version:    0.6.2
 */